home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / dfÜ / bbs / daydreambbs / developer / dreamdoor / sas_c / example / filechain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-06  |  1.6 KB  |  66 lines

  1. /*
  2.  
  3.   ***********************************************************************
  4.  
  5.          Simple example to show how to handle FileChain in door...
  6.  
  7.   ***********************************************************************
  8.  
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <proto/dddoor.h>
  15. #include <libraries/dddoor.h>
  16. #include <proto/exec.h>
  17. #include <proto/dos.h>
  18. #include <daydream.h>
  19. #include <exec/memory.h>
  20. #include <exec/nodes.h>
  21. #include <exec/lists.h>
  22.  
  23. struct    Library    *DDBase;
  24. struct    DIFace    *d;
  25.  
  26. int main(int argc, char *argv[])
  27. {
  28. struct DDPointers pointers;
  29. struct FileChainItem *currentf;
  30. struct FileChainItem *nextf;
  31.  
  32. char buffer[1024];
  33.  
  34.     DDBase=(struct Library *)OpenLibrary("dreamdoor.library",1);
  35.     if(DDBase==NULL)
  36.     {
  37.         printf("Needs DreamDoor.library V1.00+ to run\n");
  38.         exit(10);
  39.     }
  40.     d=InitDoor(argv[1]);        /* Establish link with DD */
  41.  
  42.     if(d==NULL)
  43.         {
  44.         printf("This Program Requires Microsoft Windows V3.1!\n");
  45.         CloseLibrary(DDBase);
  46.             exit(10);
  47.         }
  48.     
  49.         InquirePointers(d,&pointers);
  50.     currentf=(struct FileChainItem *)pointers.dp_FileChain;
  51.     currentf=(struct FileChainItem *)currentf->FCI_HEADER.mln_Succ;
  52.     while (currentf->FCI_HEADER.mln_Succ)
  53.         {
  54.             sprintf(buffer,"Removed:%s (%ld bytes!)\n",currentf->FCI_FILE,currentf->FCI_SIZE);
  55.         nextf=(struct FileChainItem *)currentf->FCI_HEADER.mln_Succ;
  56.         Remove((struct Node *)currentf);
  57.         FreeMem(currentf,sizeof(struct FileChainItem));
  58.             currentf=nextf;
  59.         SendString(d,buffer);
  60.         }
  61.     ReCountFiles(d);       // Update number of tagged files
  62.     CloseDoor(d);
  63.     CloseLibrary(DDBase);
  64.      exit(0);
  65. }
  66.